﻿using CodeConfigure.Models;
using CodeConfigure.Views;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace CodeConfigure.MainWindow
{
    internal class MainWindowViewModel : ObservableObject
    {
        public MainWindowViewModel()
        {
            this.DemoItems = new ObservableCollection<DemoItem>()
            {
                new DemoItem(){ Name = "工控"},
                new DemoItem(){ Name = "ERP" },
                new DemoItem(){ Name = "图表控件", 
                    DemoItemChildren = new ObservableCollection<DemoItemChild>(){
                        new DemoItemChild{ Name = "柱状图", Content = new ColumnBar()},
                        new DemoItemChild{ Name = "折线图"}
                    } },
            };
        }

        #region Property
        private ObservableCollection<DemoItem> _demoItems;
        public ObservableCollection<DemoItem> DemoItems
        {
            get => _demoItems;
            set => SetProperty(ref _demoItems, value);
        }

        private DemoItem _demoItem;
        public DemoItem DemoItem
        {
            get => _demoItem;
            set => SetProperty(ref _demoItem, value);
        }

        private string _searchKeyword;
        public string SearchKeyword
        {
            get => _searchKeyword;
            set => SetProperty(ref _searchKeyword, value);
        }

        #endregion

        #region Command
        private RelayCommand<string> _changeViewCommand;
        public RelayCommand<string> ChangeViewCommand
        {
            get
            {
                if (_changeViewCommand == null)
                {
                    _changeViewCommand = new RelayCommand<string>((name) =>{
                        MessageBox.Show(name);
                    });
                }
                return _changeViewCommand;
            }
        }
        private RelayCommand _movePrevCommand;
        public RelayCommand MovePrevCommand
        {
            get
            {
                if (_movePrevCommand == null)
                {
                    _movePrevCommand = new RelayCommand(() =>
                    {

                    });
                }
                return _movePrevCommand;
            }
        }

        private RelayCommand _moveNextCommand;
        public RelayCommand MoveNextCommand
        {
            get
            {
                if (_moveNextCommand == null)
                {
                    _moveNextCommand = new RelayCommand(() =>
                    {

                    });
                }
                return _moveNextCommand;
            }
        }
        #endregion
    }
}
